const download = require('download-git-repo')
const {frameworkUrl} = require('../../config')
// 命令行样式输出
const chalk = require('chalk')
//这里使用ora 表示正常下载中
const ora = require('ora');

const spinner = ora();
const downloadGit = (answer,project)=>{
    spinner.color = 'red';
    spinner.text = '代码正在下载'
    spinner.start()
    download(`direct:${frameworkUrl[answer.framework]}`
        ,project
        ,{clone:true}
        ,(err)=>{
            err ? spinner.fail('失败') : spinner.succeed('成功')
            console.log(chalk.blue('cd'+ project))
            console.log(chalk.red.bold('npm install'))
            console.log(chalk.rgb(255,60,90)('npm run dev'))
        })
}

module.exports = downloadGit